#pragma once

#include "RdcBuffer.h"

#include <windows.h>
#include <Cchannel.h>

namespace rdc_transport
{
    // no custom implementation
    struct IVirtChannel
    {
        virtual ~IVirtChannel() { }
        virtual void Write(Buffer* pBuffer) = 0; // may be a long time, need sync for mt
    };

    struct IReadHandler
    {
        virtual ~IReadHandler(){};
        virtual void OnRead(Buffer* pBuffer) throw() = 0;
        virtual void OnReadFail(const char* what) throw() = 0;
    };

    struct IReader
    {
        virtual ~IReader(){};
        virtual void ReadFile(PCHAR pBuffer, DWORD dwInSize, PDWORD pdwOutSize) = 0;
    };

    struct IClientVirtChannelCallback
    {
        virtual ~IClientVirtChannelCallback() { }
        virtual void OnConnect() = 0;
        virtual void OnDisconnect() = 0;
        virtual void OnTerminate() = 0;
    };

    struct IServerVirtChannelCallback
    {
        virtual ~IServerVirtChannelCallback() { }
        virtual void OnDisconnect() = 0;
        virtual void OnReconnect() = 0;
    };

    std::auto_ptr<IVirtChannel> CreateClientChannel(
        __in const char* szChannelName,
        __in PCHANNEL_ENTRY_POINTS pEntryPoints,
        __in IClientVirtChannelCallback* pCallback,
        __in IReadHandler* pReadHandler,
        __in bool bShowProtocol = false);

    std::auto_ptr<IVirtChannel> CreateServerChannel(
        __in const char* szChannelName,
        __in LPTSTR szAddinRGSName,
        __in IServerVirtChannelCallback* pCallback,
        __in IReadHandler* pReadHandler,
        __in bool bShowProtocol = false);
}